home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Disc to the Future 2
/
Disc to the Future Part II Programmer's Reference (Wayzata Technology)(6013)(1992).bin
/
MAC
/
THINKC
/
TCL1
/
__MANDEL
/
TCL_SOUR
/
CDWSWITC.C
< prev
next >
Wrap
Text File
|
1992-05-30
|
4KB
|
123 lines
/******************************************************************************
CDWSwitchboard.c
The DWSwitchboard Class
Retrieves events from the Toolbox event queue and passes messages
to the proper objects for responding to them.
SUPERCLASS = CSwitchboard
DW CHANGES
[
- changed the way mouseMoved events were processed... CSwitchboard
essentially ignored the mouseMoved event opting instead to
call DispatchCursor for each and every event.
]
******************************************************************************/
#include "Global.h"
#include "TBUtilities.h"
#include "CApplication.h"
#include "CDesktop.h"
#include "CBartender.h"
#include "CWindow.h"
#include "CDWSwitchboard.h"
#include "Commands.h"
#include "Constants.h"
#include "CAppleEvent.h"
#include "AppleEvents.h"
#include "Editions.h"
#include "EPPC.h"
/*** Global Variables ***/
extern CApplication *gApplication; /* Application object */
extern CDesktop *gDesktop; /* The visible Desktop */
extern CBartender *gBartender; /* Manages all menus */
extern CBureaucrat *gGopher; /* First in line to get commands */
extern EventRecord gLastMouseDown; /* Previous mouse down event */
extern EventRecord gLastMouseUp; /* Previous mouse up event */
extern CView *gLastViewHit; /* Last view clicked in */
extern long gSleepTime; /* Max time between events */
/*** Class Constants ***/
#define MouseMovedEvt 0xFA /* Mouse moved event code */
#define SuspendResumeEvt 0x01 /* Suspend/Resume event code */
#define ResumeEvtMask 0x1 /* Supend or Resume selector */
#define ConvertScrapMask 0x2 /* Scrap conversion flag */
/******************************************************************************
ProcessEvent
Get the next event in the queue and call the proper method to
handle it.
TCL 1.1: Previously, ProcessEvent get the event itself and did its own
dispatching. It now calls GetAnEvent to get an event from
the queue and DispatchEvent to handle the event. This
makes the event dispatch mechanism easier to modify, as
well as making integration with AppleEvents easier.
******************************************************************************/
void CDWSwitchboard::ProcessEvent( void)
{
EventRecord macEvent; /* Mac Event to be processed */
Boolean isMyEvent; /* Should program handle event? */
/* Get an event from the queue */
isMyEvent = GetAnEvent( &macEvent);
if (isMyEvent) /* We must respond to this event */
{
DispatchEvent( &macEvent);
}
else
{ /* No action required */
DoIdle( &macEvent);
}
}
/******************************************************************************
DispatchEvent
Dispatch the event to the appropriate handler.
******************************************************************************/
void CDWSwitchboard::DispatchEvent( EventRecord *macEvent)
{
Point mouseLoc;
switch (macEvent->what) { /* Branch of the type of event */
case osEvt:
/* Event type is stored in the */
/* high byte of the event message */
/* Typecast to unsigned long so */
/* we won't get sign extension */
/* when the bits are shifted */
switch ((unsigned long)macEvent->message >> 24) {
case MouseMovedEvt:
/* Since we adjust the cursor shape */
/* before handling an event, we */
/* can just idle here */
gDesktop->Prepare();
GetMouse(&mouseLoc);
gDesktop->DispatchCursor(mouseLoc, mouseRgn);
return;
}
break;
}
CSwitchboard::DispatchEvent(macEvent);
}